window.onload = function() {
        var top = document.getElementById('top')
        var imgLB1 = document.getElementById('imgLB1')
        var imgLB2 = document.getElementById('imgLB2')
        imgLB2.innerHTML = imgLB1.innerHTML

        var timer = null

        function scroll() {
            timer = setInterval(function() {
                if (top.scrollLeft >= imgLB2.offsetWidth) {
                    top.scrollLeft -= imgLB1.offsetWidth
                } else {
                    top.scrollLeft++
                }
            }, 5);
        }
        scroll();
        var contain = document.getElementById('contain')
        var imgbox = contain.getElementsByClassName('imgbox')
        var span = contain.getElementsByTagName('span')
        for (let i = 0; i < imgbox.length; i++) {
            imgbox[i].onmouseover = function() {
                span[i].style.display = 'block';
                clearInterval(timer)
            }
            imgbox[i].onmouseout = function() {
                span[i].style.display = 'none';
                scroll();
            }
        }
        //登录后显示当前用户
        if (localStorage.getItem('loginName')) {
            var links = document.querySelectorAll('#headright a')
            for (var i = 0; i < links.length; i++) {
                links[i].style.display = 'none';
            }
            document.querySelector("#loginName").style.display = 'inline-block';
            document.querySelector("#unregister").style.display = 'inline-block';
            document.querySelector('#headright span').style.display = "none";
            document.querySelector('#loginName').innerHTML = "当前账号：" + '<a href="cebiandaohanglan.html">' + localStorage.getItem('loginName') + '</a>'
        }
    }
    //注销事件
function unregister() {
    localStorage.removeItem('loginName');
    location.replace('shouye.html')
}
//导航栏固定
window.onscroll = function() {
    if (document.documentElement.scrollTop >= 80) {
        document.getElementById('bodynav').style.position = 'fixed';
        document.getElementById('bodynav').style.top = 0;
        document.getElementById('bodynav').style.left = 0;
    } else {
        document.getElementById('bodynav').style.position = 'static';
    }
}